<template>
    <el-card shadow="hover">
        <div ref="charone" style="width: 95%;height: 200px;"></div>
    </el-card>
</template>

<script setup>
import * as echarts from 'echarts'
import { ref, reactive, getCurrentInstance, onMounted } from 'vue'
const { proxy } = getCurrentInstance()

onMounted(() => {
    getCharData()
})

let data = reactive({
    charData: []
})

let getCharData = async () => {
    let res = await proxy.$api.getCharData()
    console.log('getCharData', res);
    data.charData = res
    initOne()
}

let charone = ref(null)
let initOne = () => {
    const charDom = charone.value
    const myChart = echarts.init(charDom)
    const option = {
        title: {
            text: '日销量',
            subtext: 'mobile',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left'
        },
        series: [
            {
                name: 'Access From',
                type: 'pie',
                radius: '50%',
                data: data.charData.videoData,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    myChart.setOption(option);
}


</script>

<style lang='less' scoped></style>